package com.qf.controller;

import com.github.pagehelper.PageInfo;
import com.qf.pojo.User;
import com.qf.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/user")
@Api(value = "用户接口")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/findAll")
    @ApiOperation(value = "查询用户列表")
    public List<User> findAll() {
        List<User> list = userService.findAll();
        return list;
    }

    @PostMapping("/page")
    @ApiOperation(value = "用户分页查询")
    public PageInfo<User> findPage(@ApiParam(value = "当前页") Integer currentPage,
                                   @ApiParam(value = "每页显示条数") Integer size) {
        PageInfo<User> page = userService.findPage(currentPage, size);
        return page;
    }
}
